<script type="text/javascript" src="http://www.google.com/jsapi"></script>

<script type="text/javascript">
google.load("language", "1");

var user     = {name:     '<?php echo $TARGET->get_view('user')->get('name')?>',
                email:    '<?php echo $TARGET->get_view('user')->get('email')?>',
                language: '<?php echo $TARGET->get_view('user')->get('language')?>'};

var opponent = {name:     '<?php echo $TARGET->get_view('opponent')->get('name')?>',
                email:    '<?php echo $TARGET->get_view('opponent')->get('email')?>',
                language: '<?php echo $TARGET->get_view('opponent')->get('language')?>'};

var users = { <?php echo $TARGET->get_view('opponent')->get('id')?>: opponent, 
              <?php echo $TARGET->get_view('user')->get('id')?>:     user };

var args = { server_time: '<?php echo time();?>',
             local_time : new Date(),
             user_id    : <?php echo $TARGET->get_view('user')->get('id')?>,
             dialog     : '#dialog' };


var messenger = new GMessenger(users, args);


/*    google.language.translate(text, "ru", "en", function(result) {
        $('#dialog2').append('Ru: ' + result.translation + '<br>');
    });*/

$(document).ready(function(){
    $("#speaker").keypress(function (e) {
        if (e.which == 13) {
            text = this.value;
            messenger.say(text);
            this.value = '';
        }
    });
});
</script>

<table width="100%">
<tr><td width="100%">
    <h3><?php echo $TARGET->get_view('user')->get('name') . '(' . ucfirst($TARGET->get_view('user')->get('language')) . ')';?>
        &nbsp;vs.&nbsp;
        <?php echo $TARGET->get_view('opponent')->get('name') . '(' . ucfirst($TARGET->get_view('opponent')->get('language')) . ')';?></h3>
</td></tr>
<tr><td width="100%">
    <div style="border:solid 1px;" id="dialog"></div>
</td></tr>
<tr><td>
&nbsp;
</td></tr>
<tr><td width="100%">
    <input style="width:100%;" type="text" id="speaker">
</td></tr>
</table>